// 存放所有组织架构的接口
import request from '@/utils/request'

// 查询企业的部门列表
export const getDepartment = () => {
  return request({
    url: '/company/department'
  })
}

/**
 * 新增子部门
 * @param {*} data.code 部门编码，同级部门不可重复
 * @param {*} data.introduce 介绍
 * @param {*} data.manager 负责人名称
 * @param {*} data.name 部门名称
 * @param {*} data.pid 父级部门ID
 * @returns {promise}
 */
export function addDepartment(data) {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

// 根据ID查询部门详情
export const getDepartDetail = (id) => {
  return request({
    url: `/company/department/${id}`
  })
}
// 根据ID修改部门详情
export const updateDepartment = (data) => {
  return request({
    url: `/company/department/${data.id}`,
    method: 'PUT',
    data
  })
}

// 根据ID删除部门
export const delDepartment = (id) => {
  return request({
    url: `/company/department/${id}`,
    method: 'DELETE'
  })
}

